package com.ruoyi.project.poem.incidentalmusic.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.poem.incidentalmusic.domain.IncidentalMusic;
import com.ruoyi.project.poem.incidentalmusic.mapper.IncidentalMusicMapper;
import com.ruoyi.project.poem.incidentalmusic.service.IIncidentalMusicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 背景音乐Service业务层处理
 *
 * @author shixiangwen
 * @date 2022-06-23
 */
@Service
@DataSource(DataSourceType.POEM)
public class IncidentalMusicServiceImpl implements IIncidentalMusicService {
    @Autowired
    private IncidentalMusicMapper incidentalMusicMapper;

    /**
     * 查询背景音乐
     *
     * @param id 背景音乐ID
     * @return 背景音乐
     */
    @Override
    public IncidentalMusic selectIncidentalMusicById(Long id) {
        return incidentalMusicMapper.selectIncidentalMusicById(id);
    }

    /**
     * 查询背景音乐列表
     *
     * @param incidentalMusic 背景音乐
     * @return 背景音乐
     */
    @Override
    public List<IncidentalMusic> selectIncidentalMusicList(IncidentalMusic incidentalMusic) {
        return incidentalMusicMapper.selectIncidentalMusicList(incidentalMusic);
    }

    /**
     * 新增背景音乐
     *
     * @param incidentalMusic 背景音乐
     * @return 结果
     */
    @Override
    public int insertIncidentalMusic(IncidentalMusic incidentalMusic) {
        incidentalMusic.setCreatedTime(DateUtils.getNowDate());
        return incidentalMusicMapper.insertIncidentalMusic(incidentalMusic);
    }

    /**
     * 修改背景音乐
     *
     * @param incidentalMusic 背景音乐
     * @return 结果
     */
    @Override
    public int updateIncidentalMusic(IncidentalMusic incidentalMusic) {
        return incidentalMusicMapper.updateIncidentalMusic(incidentalMusic);
    }

    /**
     * 删除背景音乐对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteIncidentalMusicByIds(String ids) {
        return incidentalMusicMapper.deleteIncidentalMusicByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除背景音乐信息
     *
     * @param id 背景音乐ID
     * @return 结果
     */
    @Override
    public int deleteIncidentalMusicById(Long id) {
        return incidentalMusicMapper.deleteIncidentalMusicById(id);
    }
}
